<link type="text/css" href="/admins/js/jquery/css/ui-lightness/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/admins/js/My97DatePicker/WdatePicker.js"></script>
<script>
</script>
<div class="admin_nrtop">
    <div class="ad_search">
        <form action="/admini/managewaybill/index/"  method="get" style="margin:0px" id="form1">
        <div class="search">
            <div class="soubox">
                <input type="text" id="quick" name="quick" value="<?php echo $this->quick?$this->quick:"";?>" placeholder="输入单号/仓库号/用户名等"/>
                <input type="hidden" id="timescope" name="timescope" value="<?php echo $this->timescope?$this->timescope:"";?>" />
                <input type="hidden" id="starttime" name="starttime" value="<?php echo $this->starttime?$this->starttime:"";?>"/>
                <input type="hidden" id="endtime" name="endtime" value="<?php echo $this->endtime?$this->endtime:"";?>" />
                <input type="hidden" id="pagesize" name="pagesize" value="<?php echo $this->pagesize?$this->pagesize:10;?>" />
                <input type="hidden" id="channelid" name="channelid" value="<?php echo $this->channelid?$this->channelid:"";?>" />
                <input type="hidden" id="cityid" name="cityid" value="<?php echo $this->cityid?$this->cityid:"";?>" />
                <input type="hidden" id="startweight" name="startweight" value="<?php echo $this->startweight?$this->startweight:"";?>"/>
                <input type="hidden" id="endweight" name="endweight" value="<?php echo $this->endweight?$this->endweight:"";?>" />
                <input type="hidden" id="startpayment" name="startpayment" value="<?php echo $this->startpayment?$this->startpayment:"";?>"/>
                <input type="hidden" id="endpayment" name="endpayment" value="<?php echo $this->endpayment?$this->endpayment:"";?>" />
                <input type="hidden" id="startmoney" name="startmoney" value="<?php echo $this->startmoney?$this->startmoney:"";?>"/>
                <input type="hidden" id="endmoney" name="endmoney" value="<?php echo $this->endmoney?$this->endmoney:"";?>" />
                <input type="hidden" id="agentid" name="agentid" value="<?php echo $this->agentId?$this->agentId:"";?>" />
                <input type="hidden" id="statusid" name="statusid" value="<?php echo $this->status===""?"":$this->status;?>" />
            </div>
            <a href="javascript:$('#form1').submit();"><span>搜索</span></a>
        </div>

        <div class="timebox">
            <div class="ad_time">
                <div class="timezdy">
                    <div class="timeselect2">
                        <span><?php if($this->timescope){
                                switch ($this->timescope) {
                                    case "week":
                                        echo "本周";
                                        break;
                                    case "lastweek":
                                        echo "上周";
                                        break;
                                    case "month":
                                        echo "本月";
                                        break;
                                    case "lastmonth":
                                        echo "上月";
                                        break;
                                    case "quarter":
                                        echo "本季";
                                        break;
                                    case "lastquarter":
                                        echo "上季";
                                        break;
                                    case "year":
                                        echo "今年";
                                        break;
                                    case "lastyear":
                                        echo "去年";
                                        break;
                                    case "day7":
                                        echo "近7天";
                                        break;
                                    case "day30":
                                        echo "近30天";
                                        break;
                                    default:
                                        echo "范围选择";
                                        break;
                                }
                            }else{echo "范围选择";}?>
                        </span><i></i>
                    </div>
                    <div class="timeslelct_xl" style="display:none;">
                        <ul>
                            <li><a href="javascript:setstart('week')">本周</a></li>
                            <li><a href="javascript:setstart('lastweek')">上周</a></li>
                            <li><a href="javascript:setstart('month')">本月</a></li>
                            <li><a href="javascript:setstart('lastmonth')">上月</a></li>
                            <li><a href="javascript:setstart('quarter')">本季</a></li>
                            <li><a href="javascript:setstart('lastquarter')">上季</a></li>
                            <li><a href="javascript:setstart('year')">今年</a></li>
                            <li><a href="javascript:setstart('lastyear')">去年</a></li>
                            <li><a href="javascript:setstart('day7')">近7天</a></li>
                            <li><a href="javascript:setstart('day30')">近30天</a></li>
                        </ul>
                    </div>
                </div>
                <div class="timefw">
                    <div class="time">
                        <!--点击后悬停样式为：<div class="timeselect t_on">-->
                        <div class="timeselect"  id="stime">
                            <span id="stimeval"><?php echo $this->starttime?$this->starttime:date("Y-m-d",mktime(0,0,0,date("m"),date("d")-90,date("Y")));?></span><i></i>
                        </div>
                        <div class="timeslelctbox">
                            <!---时间插件放此DIV-->
                        </div>
                    </div>
                    <div class="timezhi">
                        <span>至</span>
                    </div>
                    <div class="time" >
                        <div class="timeselect" id="etime">
                            <span id="etimeval"><?php echo $this->endtime?$this->endtime:date("Y-m-d");?></span><i></i>
                        </div>
                        <div class="timeslelctbox">
                            <!---时间插件放此DIV-->
                        </div>
                    </div>
                </div>
            </div>
            <div class="timeok">
                <a href="javascript:$('#form1').submit();">确定</a>
            </div>
        </div>
        <div class="xianshi">
            <label>显示：</label>
            <ul>
                <li <?php echo $this->pagesize?($this->pagesize==10?'class="xson"':""):'class="xson"'; ?>><a href="javascript:setpagesize(10)">10</a></li>
                <li <?php echo $this->pagesize?($this->pagesize==20?'class="xson"':""):""; ?>><a href="javascript:setpagesize(20)">20</a></li>
                <li <?php echo $this->pagesize?($this->pagesize==30?'class="xson"':""):""; ?>><a href="javascript:setpagesize(30)">30</a></li>
            </ul>
        </div>
        <div class="guolv1">
            <ul>
                <li><label><input id='invoice' name="invoice" type="checkbox" value="1" <?php echo $this->invoice?($this->invoice==1?"checked":""):"";?>>没制发票</label></li>
                <li><label><input id="isAddform" name="isAddform" type="checkbox" value="1" <?php echo $this->isAddform?($this->isAddform==1?"checked":""):"";?>>未打印地址</label></li>
            </ul>
        </div>
        </form>
    </div>
</div>
<div  class="biaoge">
	<div class="biaotbody">
            	<table>
                	<tr>
                    	<th class="li205">
                        	<div class="lijz"><input name="checkall" type="checkbox" id="checkall" value=""></div>
                        </th>
                    	<th class="li9">
                        	悠奇运单编号
                        </th>
                    	<th class="li9">
                        	<div class="biaoxiala">
                                <!--点击后悬停样式为：<div class="lixiala bton">-->
                                <div class="lixiala">
                                    <span>运送方式</span>
                                    <i></i>
                                </div>
                                <div class="biaoxllb" style="display:none;">
                                    <ul>
                                        <?php if($this->expresscomp){ foreach ($this->expresscomp as $eccomp) { ?>
                                            <li><a href="javascript:setchannel(<?php echo $eccomp->id; ?>)"><?php echo $eccomp->name; ?></a></li>
                                        <?php }} ?>
                                    </ul>
                                </div>
                            </div>
                        </th>
                    	<th class="li9">
                            <div class="biaoxiala">
                                <!--点击后悬停样式为：<div class="lixiala bton">-->
                                <div class="lixiala">
                                    <span>目的地</span>
                                    <i></i>
                                </div>
                                <div class="guojiaceng" style="display:none">
                                    <div class="remen">
                                            <h2>热门国家和地区</h2>
                                        <ul class="countrylist">
                                            <li><a href="javascript:void(0)" id="c_us" cid="1">美国</a></li>
                                            <li><a href="javascript:void(0)" cid="2">加拿大</a></li>
                                            <li><a href="javascript:void(0)" cid="3">澳大利亚</a></li>
                                            <li><a href="javascript:void(0)" cid="47">日本</a></li>
                                            <li><a href="javascript:void(0)" cid="39">台湾</a></li>
                                            <li><a href="javascript:void(0)" cid="4">新西兰</a></li>
                                            <li><a href="javascript:void(0)" cid="5">英国</a></li>
                                            <li><a href="javascript:void(0)" cid="42">马来西亚</a></li>
                                        </ul>
                                    </div>
                                    <div class="allcountry">
                                        <h2>全部国家和地区</h2>
                                        <ul class="countryzm">
                                            <? foreach ($this->words as $char){ ?>
                                                <li <?= $char=='A'?'class="zmon"':'' ?>><a href="javascript:void(0)"><?= $char ?></a></li>
                                            <? } ?>
                                        </ul>
                                        <div id="countryTab">
                                            <? foreach ($this->words as $char){ ?>
                                            <ul class="countrylist"  <?= $char=='A'?'':'style="display:none"' ?>>
                                               <? $citys= Application_Model_city::GetBySortCode($char);
                                                    foreach ($citys as $city){
                                               ?>
                                                <li><a href="javascript:void(0)" cid="<?=$city->Id ?>"><?= $city->Name ?></a></li>
                                                <? } ?>
                                            </ul>
                                            <? } ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </th>
                    	<th class="li10">
                        	<div class="lileft">收件人</div>
                        </th>
                        <th class="li7">
                            <div class="biaoxiala">
                                <div class="lixiala">
                                    <span>物品净重(kg)</span>
                                    <i></i>
                                </div>
                                <div class="biaofw" style="display:none;">
                                	<input type="text" id="weightstart" name="weightstart" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
                                        <span>至</span>
                                        <input type="text" id="weightend" name="weightend" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
                                        <a href="javascript:setweight()">确定</a>
                                </div>
                            </div>
                        </th>
                    	<th class="li7">
                        	<div class="biaoxiala">
                                <div class="lixiala">
                                    <span>预付重量(kg)</span>
                                    <i></i>
                                </div>
                                <div class="biaofw" style="display:none;">
                                	<input type="text" id="paymentstart" name="paymentstart" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
                                        <span>至</span>
                                        <input type="text" id="paymentend" name="paymentend" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
                                        <a href="javascript:setpayment()">确定</a>
                                </div>
                            </div>
                        </th>
                    	<th class="li7">
                        	<div class="biaoxiala">
                                <div class="lixiala">
                                    <span>预付款(rmb)</span>
                                    <i></i>
                                </div>
                                <div class="biaofw" style="display:none;">
                                	<input type="text" id="moneystart" name="moneystart" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
                                        <span>至</span>
                                        <input type="text" id="moneyend" name="moneyend" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">
                                        <a href="javascript:setmoney()">确定</a>
                                </div>
                            </div>
                        </th>
                    	<th class="li7">
                            <div class="biaoxiala">
                                <div class="lixiala">
                                    <span>发货渠道</span>
                                    <i></i>
                                </div>
                                <div class="biaoxllb" style="display:none;">
                                    <ul>
                                    	<?php if($this->agentcomp){ foreach ($this->agentcomp as $eccomp) { ?>
                                            <li><a href="javascript:setagent(<?php echo $eccomp->id; ?>)"><?php echo $eccomp->name; ?></a></li>
                                        <?php }} ?>
                                    </ul>
                                </div>
                            </div>
                        </th>
                    	<th class="li10"><div class="lileft">渠道单号</div></th>
                    	<th class="li10"><div class="lileft">转单号</div></th>
                    	<th class="li7">
                        	<div class="biaoxiala">
                                <div class="lixiala">
                                    <span>状态</span>
                                    <i></i>
                                </div>
                                <div class="biaoxllb" style="display:none;">
                                    <ul>
                                    	<?php if($this->arrstatus){ foreach ($this->arrstatus as $key => $eccomp) { ?>
                                            <li><a href="javascript:setstatus(<?php echo $key; ?>)"><?php echo $eccomp; ?></a></li>
                                        <?php }} ?>
                                    </ul>
                                </div>
                            </div>
                        </th>
                    	<th class="li505"><div class="liright">操作</div></th>
                    </tr>
                </table>
            </div>
           <?php if($this->channelid || $this->cityid || $this->startweight || $this->startpayment || $this->startmoney || $this->agentId || ($this->status !== "" && $this->status !== null)){?>
              <div class="xzinfo">
            	<ul>
                    <?php if($this->channelid){ ?><li><div class="xzinfobox"><span><?php $channelItem = Application_Model_Express::load($this->channelid);echo $channelItem->name;?></span><a href="javascript:removeset('channel')" title="撤销"><i>撤销</i></a></div></li><?php }?>
                    <?php if($this->cityid){ ?><li><div class="xzinfobox"><span><?php $cityItem = Application_Model_city::load($this->cityid);echo $cityItem->name;?></span><a href="javascript:removeset('city')" title="撤销"><i>撤销</i></a></div></li><?php }?>
                    <?php if($this->startweight){ ?><li><div class="xzinfobox"><span>物品净重：<?php echo $this->startweight."kg 至 ".$this->endweight."kg";?></span><a href="javascript:removeset('weight')" title="撤销"><i>撤销</i></a></div></li><?php }?>
                    <?php if($this->startpayment){ ?><li><div class="xzinfobox"><span>预付重量：<?php echo $this->startpayment."kg 至 ".$this->endpayment."kg";?></span><a href="javascript:removeset('payment')" title="撤销"><i>撤销</i></a></div></li><?php }?>
                    <?php if($this->startmoney){ ?><li><div class="xzinfobox"><span>预付金额：<?php echo "￥".$this->startmoney." 至 ".$this->startmoney;?></span><a href="javascript:removeset('money')" title="撤销"><i>撤销</i></a></div></li><?php }?>
                    <?php if($this->agentId){ ?><li><div class="xzinfobox"><span><?php $agentItem = Application_Model_AgentCompany::load($this->agentId);echo $agentItem->name;?></span><a href="javascript:removeset('agent')" title="撤销"><i>撤销</i></a></div></li><?php }?>
                    <?php if($this->status === "" && $this->status !== null){}else{ ?><li><div class="xzinfobox"><span><?php echo $this->arrstatus["$this->status"];?></span><a href="javascript:removeset('status')" title="撤销"><i>撤销</i></a></div></li><?php }?>
                </ul>
            </div>
           <?php }?>
            <div class="table2">
                <?php 
                    if($this->billlist){
                        
                    foreach ($this->billlist as $key => $Item) {?>
                    <?php $billRemark = Application_Model_Remark::getObjectRemark($Item->id); ?>
            	<div class="tablebox">
                    <table>
                    <tr <?php echo in_array($Item->user->id,$this->paypalBill) ? "" : "style='display:none;'" ?>>
                            <td colspan="6" style="padding-left: 20px;color: #c00;">
                               客户第一次国际信用卡支付，24小时风险审核后自动解除服务限制！
                            </td>
                        </tr>
                    	<tr class="trhui">
                            <td class="li205"><div class="lijz"><input type="checkbox" value="<?php echo $Item->id;?>" class="checkbox-del" name='checkbox' <?php if(!$Item->statusUnify){echo "disabled='true'"; }?> /></div></td>
                            <td colspan="12" class="td_<?php echo $Item->Id;?>">
                                <div class="yundangk">
                                    <p><span>提交：<?php echo $Item->dateCreated;?></span><span>付款：<?php echo $Item->datePaid;?></span>
                                        <span>仓库号：<a href="/admini/managestore/index/nostore/<?php echo $Item->user->storeno; ?>" ><?php echo $Item->user->storeno;?></a>
                                        </span><span>用户名：<a href="/admini/manageuser/userdetail/id/<?php echo $Item->userId; ?>" ><?php echo $Item->user->nikename;?></a></span></p>
                                </div>
                                <div class="ydtishi">
                                        <?php 
                                            $premiumFee = $Item->getFeeByType(Application_Model_FeeType::RatePremiumFee);
                                            $agentLog = Application_Model_WayLog::getByWayIdInteriorType($Item->id, Application_Model_WayLog::Type_BillAffirmAgent); 
                                        ?>
                                <?php 
                                        $waybill=Application_Model_wayBillItem::load($Item->id);
                                        if($waybill!=''){
                                            foreach($waybill->getItems() as $storeItem){
                                            $items = $storeItem->StoreIdByItem;
                                            $locationNos=$items->locationNo;
                                        if(empty($locationNos) || $locationNos==NULL){ ?>
                                              <div title="暂无库位" style="cursor:pointer;float:left;width:16px;height:16px;background: url(/admins/images/hj.png) no-repeat;"></div>  
                                    <?php break;} }}?>
                                    <?php if($premiumFee > 0) { ?><a class="ts0" href="javascript:void(0)" title="已投保">已投保</a><?php }?>
                                    <?php if($Item->isInvoice == 1){?><a class="ts1" href="/admini/managewaybill/preview/id/<?php echo $Item->id;?>" title="已制发票" >已制发票</a><?php }?>
                                    <?php if($Item->isAddform == 1){?><a class="ts2" href="/admini/managewaybill/addform/id/<?php echo $Item->id;?>" title="已打印地址" >已打印地址</a><?php }?>
                                    <?php if($Item->problem == Application_Model_wayBillItem::Problem_Appear){?><a class="ts3" href="javascript:void(0)" id='issue' title="问题包裹">问题包裹</a><?php }?>
                                    <?php if($Item->problem == Application_Model_wayBillItem::Problem_Aolve || $Item->problem == Application_Model_wayBillItem::Problem_Cancel){?><a class="ts3_" href="javascript:void(0)" id='issue' title="问题包裹">问题包裹</a><?php }?>
                                    <?php if($Item->interior >= Application_Model_wayBillItem::Interior_PickError && $Item->interior!= Application_Model_wayBillItem::Interior_Achieve){?>
                                    <a class="ts4" href="javascript:void(0)" title="预警提示">预警提示</a><?php }?>
                                    <?php if($Item->interiorRemark != "" || $billRemark) { ?><a class="ts6" href="javascript:void(0)" title="<?php echo $Item->InteriorRemark;?>">内部备注</a><?php } ?>
                                    <?php if($Item->interior == Application_Model_wayBillItem::Interior_PickError){ ?><a class="ts6" href="/admini/managewaybill/picking/id/<?php echo $Item->id;?>" title="拣货异常" >拣货异常</a><?php } ?>
                                </div>
                            </td>
                        </tr>
                    	<tr>
                            <td class="li205"></td>
                            <td class="li9">
                                <div class="yubm"><a href="<?php echo $Item->billurl;?>"><?php echo $Item->billNo;?></a></div>
                            </td>
                            <td class="li9"><div class="lileft"><?php echo $Item->ExpressBy!=null?$Item->ExpressBy->name:"";?></div></td>
                            <td class="li9"><div class="lileft"><?php echo $Item->UserCity?$Item->UserCity->name:"";?></div></td>
                            <td class="li10"><div class="lileft"><?php echo $Item->consignee;?></div></td>
                            <td class="li7"><div class="lileft"><?php echo $Item->productWeight/1000;?></div></td>
                            <td class="li7"><div class="lileft"><?php if ($Item->ExpressBy->isVolume == 1) {
                                    if ($Item->volumeWeight > ($Item->productWeight + $Item->bagWeight)) {
                                        echo ($Item->volumeWeight / 1000)."kg(体积)" ;
                                    } else {
                                        echo (($Item->productWeight + $Item->bagWeight) / 1000)."kg(重量)" ;;
                                    }
                                } else {
                                    echo (($Item->productWeight + $Item->bagWeight) / 1000)."kg(重量)" ;;
                                }?></div></td>
                            <td class="li7"><div class="lileft"><?php echo $Item->getFeeByType(Application_Model_FeeType::EstimateSum);?></div></td>
                            <td class="li7"><div class="lileft"><?php echo $agentLog?$agentLog->DescriptionByAgent->name:($Item->agentname?$Item->agentname->name:"暂无");?></div></td>
                            <td class="li10"><div class="lileft"><?php echo $Item->agentNo?$Item->agentNo:"暂无";?></div></td>
                            <td class="li10"><div class="lileft"><?php echo $Item->logistics?$Item->logistics:"暂无";?></div></td>
                            <td class="li7"><div class="lileft"><?php echo ($Item->problem == Application_Model_wayBillItem::Problem_Cancel?"取消":$Item->interiorname);?></div></td>
                            <td class="li505">
                                <div class="lixlnav">
                                    <a class="xlnavxq" href="/admini/managewaybill/billaccep/id/<?php echo $Item->id;?>" >详情</a>
                                    <div class="xlnavlistbox" >
                                        <a class="xlnavsj" href="javascript:void(0)"><i></i></a>
                                        <div class="xlnavlist" style="display:none;">
                                            <ul>
                                                <li><a href="/admini/managewaybill/invoice/id/<?php echo $Item->id;?>" >写发票</a></li>
                                                <li><a href="javascript:void(0)" class="wayRemark" name='<?php echo $Item->id;?>'>备注</a></li>
                                                <li><a href="javascript:void(0)" id='cancel' name='<?php echo $Item->id;?>'>取消</a></li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
                <?php } } else { echo '<div class="tablebox">暂时无数据</div>';}?>
            </div>
    </div>
<div class="toolbar">
    <?php if($this->stype == Application_Model_wayBillItem::Interior_AffirmChannel && $this->billlist){ ?>
    <div class="qunx">
        <ul>
            <li><a class="anvbotton" href="/admini/managewaybill/outstorage" id="printOut" name="printOut"><span>打印交接单</span></a></li>
            <li><a class="anvbotton" href="javascript:void(0)" id="AffirmChannel" name="AffirmChannel"><span>交运</span></a></li>
            <li><a class="anvbotton4" href="javascript:void(0)" id="ckall" name="ckall"><span>全选</span></a></li>
        </ul>
    </div>
    <?php } ?>
<?php
echo $this->partial('paging.phtml', array("pages" => $this->billall,"pamas"=>"quick=$this->quick&timescope=$this->timescope&starttime=$this->starttime&endtime=$this->endtime&pagesize=$this->pagesize&channelid=$this->channelid&cityid=$this->cityid&startweight=$this->startweight&endweight=$this->endweight&startpayment=$this->startpayment&endpayment=$this->endpayment&startmoney=$this->startmoney&endmoney=$this->endmoney&agentid=$this->agentId&statusid=$this->status"));        
?>
</div>
<div class="tanchuang" style="display:none;">
    <div class="nui-msgbox">
        <div class="nui-msgbox-hd" id="uuchInterior">悠奇内部备注</div>
        <a class="nui-msgbox-close" title="关闭"><b></b></a>
    </div>
    <div class="wenti_box" id="problemComm">
        <div class="wt_center" style="height:350px;">
            
        </div>
        <div class="wt_caozuo">
            <textarea name="wayRemark" cols="" rows="" id="wayRemark"></textarea>
            <input type="hidden" id="addRemarkWayId" name="addRemarkWayId" value=""/>
            <a class="wt_liuyan" href="javascript:void(0)" id="addIndexRemark"><span>留言</span></a>
        </div>
    </div>    
</div>
<div class="houtai_overlay" style="display:none;"></div>
<table>    
<tfoot>
      <tr>
          <td colspan="2">　
              &nbsp;&nbsp;&nbsp;<button class="button" id="csv-button" style="background-color: #1668A4;width: 80px;height: 30px;color: white;font-size: 14px;border-radius:8px;">导出csv</button>
              <?php if($this->status == Application_Model_wayBillItem::Interior_Singleno || $this->status == Application_Model_wayBillItem::Interior_OutTransportation || $this->stus == Application_Model_wayBillItem::Interior_Singleno || $this->stus == Application_Model_wayBillItem::Interior_OutTransportation){ ?>
              &nbsp;&nbsp;&nbsp;<button class="button" id="OutTransportation-button" style="background-color: #f60;width: 80px;height: 30px;color: white;font-size: 14px;border-radius:8px;">设置已上网</button>
              <?php } ?>
              <?php if($this->status == Application_Model_wayBillItem::Interior_Transportation || $this->status == Application_Model_wayBillItem::Interior_Overachieve || $this->stus == Application_Model_wayBillItem::Interior_Transportation || $this->stus == Application_Model_wayBillItem::Interior_Overachieve){ ?>
              &nbsp;&nbsp;&nbsp;<button class="button" id="Overachieve-button" style="background-color: #f60;width: 80px;height: 30px;color: white;font-size: 14px;border-radius:8px;">设置已完成</button>
              <?php } ?>
          </td></tr>
</tfoot>    
</table>
    
<script>
    $(function(){
        $('a[href*="billaccep"]').each(function(index,item){
            var sp = '?';
            if($(item).attr('href').indexOf('?')>0){
                sp = '&';
            }
            $(item).attr('href',$(item).attr('href')+sp+'_rf='+encodeURIComponent(window.location));
        });
    });
    $('.soubox label').click(function(){
            $(this).parent().find('input').focus();
    });
    $(".timezdy").click(function(){
        $(".timezdy .timeselect2").attr("class","timeselect2 timeon");
        $(".timeslelct_xl").attr("style","display:block;");
    });
    $(".timezdy").mouseleave(function(){
       $(".timeselect2").attr("class","timeselect2");
       $(".timeslelct_xl").attr("style","display:none;");
    });
    $("#stime").click(function(){
        $(this).attr("class","timeselect t_on");
        WdatePicker({el:'stimeval',vel:'starttime',onpicked:function(){
                $("#stime,#etime").attr("class","timeselect");
                $(".soubox #timescope").val("");
        }});
    });
    $("#etime").click(function(){
        $(this).attr("class","timeselect t_on");
        WdatePicker({el:'etimeval',vel:'endtime',onpicked:function(){
                $("#stime,#etime").attr("class","timeselect");
                $(".soubox #timescope").val("");
        }});
    });
    $("#invoice:checkbox").click(function(){
        $('#form1').submit();
    });
    $("#isAddform:checkbox").click(function(){
        $('#form1').submit();
    });
    $(".lixiala").click(function(){
        $(".lixiala").attr("class","lixiala");
        $(".lixiala").next("div").attr("style","display:none;");
    
        $(this).attr("class","lixiala bton");
        $(this).next("div").attr("style","display:block;");
    });
//    $(".biaoxiala").click(function(){
//        $(".lixiala").attr("class","lixiala");
//        $(".lixiala").next("div").attr("style","display:none;");
//    });
    $(document).bind("click",function(e){
        var target  = $(e.target);
        if(target.closest(".biaoxiala").length == 0){
            $(".lixiala").attr("class","lixiala");
            $(".lixiala").next("div").attr("style","display:none;");
        }
        if(target.closest("#stime").length == 0){
            $("#stime").attr("class","timeselect");
        }
        if(target.closest("#etime").length == 0){
            $("#etime").attr("class","timeselect");
        }
   });
    $('.countryzm a').each(function(index,item){
        $(item).click(function(){
            $('.countryzm li.zmon').removeClass('zmon');
            $(this).parent().addClass('zmon');
            $('#countryTab ul').hide();
            $('#countryTab ul').eq(index).show();
            return false;
        });
    });
     $('.countrylist a').bind('click',function(){
         $(".soubox #cityid").val($(this).attr('cid'));
         $('#form1').submit();
     });
    function setweight()
    {
        var weightstart = $("#weightstart").val();
        var weightend = $("#weightend").val();
        var arrWs = weightstart.split(".");
        var arrWe = weightend.split(".");
        if($.trim(weightstart) == ""){
            alert("开始物品净重不能为空");
            return false;
        }else if(arrWs.length>2 ){
            if( !$.isNumeric(arrWs[0]) || !$.isNumeric(arrWs[1])){
                alert("开始物品净重格式错误");
                return false;
            }
        }else{
            $(".soubox #startweight").val(weightstart);
        }
        if($.trim(weightend) == ""){
            alert("结束物品净重不能为空");
            return false;
        }else if(arrWe.length>2 ){
            if( !$.isNumeric(arrWe[0]) || !$.isNumeric(arrWe[1])){
                alert("结束物品净重格式错误");
                return false;
            }
        }else{
            $(".soubox #endweight").val(weightend);
        }
        $('#form1').submit();
    }
    function setpayment()
    {
        var weightstart = $("#paymentstart").val();
        var weightend = $("#paymentend").val();
        var arrWs = weightstart.split(".");
        var arrWe = weightend.split(".");
        if($.trim(weightstart) == ""){
            alert("开始预付重量不能为空");
            return false;
        }else if(arrWs.length>2 ){
            if( !$.isNumeric(arrWs[0]) || !$.isNumeric(arrWs[1])){
                alert("开始预付重量格式错误");
                return false;
            }
        }else{
            $(".soubox #startpayment").val(weightstart);
        }
        if($.trim(weightend) == ""){
            alert("结束物预付重量不能为空");
            return false;
        }else if(arrWe.length>2 ){
            if( !$.isNumeric(arrWe[0]) || !$.isNumeric(arrWe[1])){
                alert("结束预付重量格式错误");
                return false;
            }
        }else{
            $(".soubox #endpayment").val(weightend);
        }
        $('#form1').submit();
    }
    function setmoney()
    {
        var moneystart = $("#moneystart").val();
        var moneyend = $("#moneyend").val();
        var arrMs = moneystart.split(".");
        var arrMe = moneyend.split(".");
        if($.trim(moneystart) == ""){
            alert("开始预付款不能为空");
            return false;
        }else if(arrMs.length>2 ){
            if( !$.isNumeric(arrMs[0]) || !$.isNumeric(arrMs[1])){
                alert("开始预付款格式错误");
                return false;
            }
        }else{
            $(".soubox #startmoney").val(moneystart);
        }
        if($.trim(moneyend) == ""){
            alert("结束预付款不能为空");
            return false;
        }else if(arrMe.length>2 ){
            if( !$.isNumeric(arrMe[0]) || !$.isNumeric(arrMe[1])){
                alert("结束预付款格式错误");
                return false;
            }
        }else{
            $(".soubox #endmoney").val(moneyend);
        }
        $('#form1').submit();
    }
    function setchannel(id)
    {
        $(".soubox #channelid").val(id);
        $('#form1').submit();
    }
    function setagent(id)
    {
        $(".soubox #agentid").val(id);
        $('#form1').submit();
    }
    function setstatus(id)
    {
        $(".soubox #statusid").val(id);
        $('#form1').submit();
    }
    function removeset(type)
    {
        if(type == "channel"){
            $(".soubox #channelid").val("");
        }else if(type == "city"){
            $(".soubox #cityid").val("");
        }else if(type == "weight"){
            $(".soubox #startweight").val("");
            $(".soubox #endweight").val("");
        }else if(type == "payment"){
            $(".soubox #startpayment").val("");
            $(".soubox #endpayment").val("");
        }else if(type == "money"){
            $(".soubox #startmoney").val("");
            $(".soubox #endmoney").val("");
        }else if(type == "agent"){
            $(".soubox #agentid").val("");
        }else if(type == "status"){
            $(".soubox #statusid").val("");
        }
        $('#form1').submit();
    }
    $(".xlnavsj").live("mousemove",function(){
        $(this).next("div").attr("style","display:block;");
    });
    $(".lixlnav").mouseleave(function(){
        $(".xlnavsj").next("div").attr("style","display:none;");
    });
    
    $("#cancel").on('click',function(){
        var billid = $(this).attr('name');
        if(confirm("您确定取消该运单？","提示信息")){            
            $.ajax({    
                type: 'POST',
                url: '/admini/managewaybill/cancel/id/'+billid,
                success: function(data) {
                    if(data == 2){
                        alert("取消成功！");
                    }else if(data == 22){
                        alert("只能撤销未受理和受理中的运单");
                    }else{
                        alert("发生未知错误，请重新操作");
                    }
                    location.href='/admini/managewaybill/index';
                }
            });
        }
        return false;
    });
    function setpagesize(size)
    {
        $(".xianshi ul li").attr("class","");
        $(".soubox #pagesize").val(size);
        $('#form1').submit();
    }
    function setstart(start)
    {
        $(".soubox #timescope").val(start);
        $(".timeselect2").attr("class","timeselect2");
        $(".timeslelct_xl").attr("style","display:none;");
        $('#form1').submit();
    }
    $(".toolbar #ckall").click(function(){
        $("input[name='checkbox']").attr("checked",true);
        $("input[name='checkall']").attr("checked",true);
        $("input[name='checkbox'][disabled='true']").attr("checked",false);
    });
    $("input[name='checkall']").click(function(){
       var ck = $("input[name='checkall']").attr("checked");
       if(ck == "checked"){
           $("input[name='checkbox']").attr("checked",true);
           $("input[name='checkbox'][disabled='true']").attr("checked",false);
       }else{
           $("input[name='checkbox']").attr("checked",false);
       }
    });
    $("#AffirmChannel").click(function(){
        var idlist = '';
         $('input[name="checkbox"]:checked').each(function(){    
             if($(this).attr("disabled") != "true"){
		idlist+= $(this).val()+',';
             }else{
                 alert("对不起，您选择的运单有不可交运的运单");
             }
	});
        if(idlist == ""){
            alert("请选择运单！");
        }else{
            if(confirm("您确定交运该运单（"+idlist+"）吗？","提示信息")){            
                $.ajax({    
                    type: 'POST',
                    url: '/admini/managewaybill/affirm/idlist/'+idlist,
                    success: function(data) {
                        if(data == 1){
                            alert("交运成功！");
                            location.href='/admini/managewaybill/index/stus/<?php echo Application_Model_wayBillItem::Interior_Outstorage;?>';
                        }else{
                            alert("发生未知错误，请重新操作");
                            //location.href='/admini/managewaybill/index/stus/<?php echo Application_Model_wayBillItem::Interior_AffirmChannel;?>';
                        }
                    }
                });
            }
        }
    });
    
    $('#csv-button').click(function(){
        if(confirm("确定要导出！")){
            $('#pagesize').val('1000');
            $('.soubox').html($('.soubox').html()+'<input type="hidden" id="export" name="export" value="csv" />');
            $('#form1').submit();
            $('#pagesize').val('10');
            $('#export').val("");
        }
    });
    
    $(".wayRemark").click(function(){
        var wayId = $(this).attr("name");
        $("#addRemarkWayId").val(wayId);
        $.ajax({    
            type: 'POST',
            url: '/admini/managewaybill/indexremark/wayId/'+wayId,
            success: function(data) {
                if(data != ""){
                    $("div.tanchuang .wt_center").html(data);
                    $("div.houtai_overlay").show();
                    $("div.tanchuang").show();
                }else{
                    alert("发生未知错误，请重新操作");
                }
            }
        });
    });
    $(".nui-msgbox-close").live("click",function(){
        $("div.houtai_overlay").hide();
        $("div.tanchuang").hide();
    });
    $("#addIndexRemark").click(function(){
        var wayId = $("#addRemarkWayId").val();
        var wayRemark = $("#wayRemark").val();
        $.ajax({    
            type: 'POST',
            url: '/admini/managewaybill/addindexremark/wayId/'+wayId+"/interiorcontent/"+wayRemark,
            success: function(data) {
                if(data.type ==1){
                    var table = $("div.tanchuang .wt_center").children('table');
                    if(0 < table.length){
                        table.children('tbody').append('<tr><td>' + data.indexRemark.operator + ' 在' + data.indexRemark.createdAt + ' 留言</td><td>' + data.indexRemark.content + '</td><td style="padding:0 0 0 38px;"><a href="javascript:void(0)" title="删除该备注" onclick="javascript:deleteWaybillRemark($(this),' + data.indexRemark.id + ')">删除</a></td></tr>');
                    }else{
                        var html = '<table><tbody>';
                            html += '<tr><td>' + data.indexRemark.operator + ' 在' + data.indexRemark.createdAt + ' 留言</td><td>' + data.indexRemark.content + '</td><td style="padding:0 0 0 38px;"><a href="javascript:void(0)" title="删除该备注" onclick="javascript:deleteWaybillRemark($(this),' + data.indexRemark.id + ')">删除</a></td></tr>';
                        html += '</tbody></table>';
                        $("div.tanchuang .wt_center").html(html);
                    }
                  //  $("div.tanchuang .wt_center").html(data.indexRemark);
                    if(data.isRemark == 1){
                        $(".td_"+wayId+" .ydtishi").append('<a class="ts6" href="javascript:void(0)" title="内部备注">内部备注</a>');
                    }
                    $("#wayRemark").val("");
                    $("div.houtai_overlay").show();
                    $("div.tanchuang").show();
                }else{
                    alert("发生未知错误，请重新操作");
                }
            }
        });
    });
    $("#OutTransportation-button").click(function(){
        var idlist = '';
        $('input[name="checkbox"]:checked').each(function(){    
             if($(this).attr("disabled") != "true"){
		idlist+= $(this).val()+',';
             }else{
                 alert("对不起，您选择的运单有不可交运的运单");
             }
	});
        if(idlist == ""){
            alert("请选择运单！");
        }else{
            if(confirm("您确定这些运单已上网吗？","提示信息")){            
                $.ajax({    
                    type: 'POST',
                    url: '/admini/managewaybill/batchtransportation/idlist/'+idlist,
                    success: function(data) {
                        if(data == 1){
                            alert("更新成功！");
                        }else{
                            alert("发生未知错误，请重新操作");
                        }
                        location.reload();
                    }
                });
            }
        }
    });
    $("#Overachieve-button").click(function(){
        var idlist = '';
        $('input[name="checkbox"]:checked').each(function(){    
             if($(this).attr("disabled") != "true"){
		idlist+= $(this).val()+',';
             }else{
                 alert("对不起，您选择的运单有不可交运的运单");
             }
	});
        if(idlist == ""){
            alert("请选择运单！");
        }else{
            if(confirm("您确定这些运单已完成吗？","提示信息")){            
                $.ajax({    
                    type: 'POST',
                    url: '/admini/managewaybill/batchachieve/idlist/'+idlist,
                    success: function(data) {
                        if(data == 1){
                            alert("更新成功！");
                        }else{
                            alert("发生未知错误，请重新操作");
                        }
                        location.reload();
                    }
                });
            }
        }
    });
    
    function deleteWaybillRemark(obj,id) {
        if (confirm("您确定删除该备注？", "提示信息")) {
            $.ajax({
                type: 'GET',
                url: '/admini/managewaybill/deleteremark/id/' + id,
                success: function(data) {
                    if (data == 1) {
                        alert("删除备注成功！");
                        obj.closest('tr').remove();
                    } else {
                        alert("发生未知错误，请重新操作");
                    }
                }
            });
        }
    }
    
</script>
